function animate(obj,target){

    clearInterval(obj.time);

    obj.time = setInterval(function(){
        let step = (target-obj.offsetLeft)/10;
       step = step>0?Math.ceil(step):Math.floor(step);

        if(obj.offsetLeft==target){
            clearInterval(obj.time);
        }

        obj.style.left=obj.offsetLeft + step + 'px';
    },15);
}